class MyError(Exception):
    pass


try:
    a = 10
    b = 20
    raise MyError('Something went wrong', reason='Unknown', a=a, b=b)
except MyError as e:
    print(e.args)  # 输出：('Something went wrong',)
    print(e.kwargs)  # 输出：{'reason': 'Unknown',